<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<script src="${pageContext.request.contextPath}/erp/js/showImg.js" type="text/javascript"></script>
<style type="text/css">
	img{
		width: 150px;
		height: 150px;
		cursor: pointer;
	}
</style>
<div id="update_station_div">
  		<form action="${pageContext.request.contextPath}/station/update" class="pageForm required-validate" 
  		 method="post" enctype="multipart/form-data" onsubmit="return iframeCallback(this,navTabAjaxDone);"
  		 id="update_station_form">	
			<div layouth="56" class="pageFormContent" style="height: 186px; overflow: auto;">
				<p>
					<label>总部编码：</label>
					<input type="text" readonly="readonly" id="hqId" name="hqId" value="${bean.hqId }"/>
				</p>
				<p>
					<label>总部名称：</label>
					<input type="text" readonly="readonly" id="hqName" name="hqName" value="${bean.hqName }"/>
				</p>
				<p>
					<label>油站站点编码：</label>
					<input type="text" size="20" readonly="readonly" name="stationId" id="stationId" value="${bean.stationId }"/>
				</p>
				<p>
					<label>油站站点名称：</label>
					<input type="text" size="20" readonly="readonly" name="stationName" id="stationName" value="${bean.stationName }"/>
				</p>
				<p>
					<label>营业执照名称：</label>
					<input type="text" size="20" class="required textInput" name="registeredName" id="registeredName" value="${bean.registeredName }"/>
				</p>
				<p>
					<label>营业执照编号：</label>
					<input type="text" size="20" class="required textInput" name="registeredNumber" id="registeredNumber" value="${bean.registeredNumber }"/>
				</p>
				<p>
					<label>法人/代理人：</label>
					<input type="text" size="20" class="required textInput" name="legalRepresentative" id="legalRepresentative" value="${bean.legalRepresentative }"/>
				</p>
				<p>
					<label>联系人：</label>
					<input type="text" size="20" class="required textInput" name="contactsName" id="contactsName" value="${bean.contactsName }"/>
				</p>
				<p>
					<label>电话：</label>
					<input type="text" size="20" class="required textInput" name="phoneNum" id="phoneNum" value="${bean.phoneNum }"/>
				</p>
				<p>
					<label>邮箱：</label>
					<input type="text" size="20" class="required textInput" name="email" id="email" value="${bean.email }"/>
				</p>
				<p>
					<label>油枪数量：</label>
					<input type="text" size="20" class="required textInput" name="fpCnt" id="fpCnt" value="${bean.fpCnt }"/>
				</p>
				<p>
					<label>油机数量：</label>
					<input type="text" size="20" class="required textInput" name="dispenserCnt" id="dispenserCnt" value="${bean.dispenserCnt }"/>
				</p>
				<p>
					<label>油机品牌：</label>
					<input type="text" size="20" class="required textInput" name="dispenserBrand" id="dispenserBrand" value="${bean.dispenserBrand }"/>
				</p>
<!-- 				<p> -->
<!-- 					<label>password：</label> -->
<%-- 					<input type="text" size="20" class="textInput" name="password" id="password" value="${bean.password }"/> --%>
<!-- 				</p> -->
				<p>
					<label>备注：</label>
					<input type="text" size="20" class="textInput" name="memo" id="memo" value="${bean.memo }"/>
				</p>
				<p style="width: 500px;">
					<label>地址：</label>
			           <select data-placeholder="省份" id="provinceId" name="provinceId" class="select" >
			           </select>
			           <input type="hidden" size="15" class="textInput" name="province" id="province" value="${bean.province }">
			           <input type="hidden" size="15" class="textInput" name="old_provinceId" id="old_provinceId" value="${bean.provinceId }">
			           <select data-placeholder="城市" name="cityId" id="cityId" class="form-control" data-rel="chosen">
			           		<option>选择城市</option>
			          	</select>
			          	<input type="hidden" size="15" class="textInput" name="old_cityId" id="old_cityId" value="${bean.cityId }">
			          	<input type="hidden" size="15" class="textInput" name="city" id="city" value="${bean.city }">
	<!-- 		           <select data-placeholder="区域" name="area" id="areaId" class="form-control" data-rel="chosen"> -->
	<!-- 		               <option>选择区域</option> -->
	<!-- 		           </select> -->
				</p>
				<p style="width: 200px;">
			      <input id="address" name="address" class="required textInput" type="text" value="${bean.address }" />
				</p>
				
				<div class="divider"></div>
				<p style="height: 150px;">
					<label>油站外观：</label>
					<c:choose>
					   <c:when test="${saImg== null}"> 
	  						<img src='${pageContext.request.contextPath}/images/upload.png' name="StationAppearance_img" id="StationAppearance_img" onclick="show_img.open_file('saImg')">
					   </c:when>
					   <c:otherwise>
					   		<img src='${pageContext.request.contextPath}/Common/downloadPhoto?url=${saImg}' name="StationAppearance_img" id="StationAppearance_img" onclick="show_img.open_file('saImg')">
					   </c:otherwise>
					</c:choose>
					<input style="display: none" type="file" id="saImg" name="saImg" onchange="show_img.change('saImg','StationAppearance_img')"/>
  				</p>
				<p style="height: 150px;">
					<label>收银台：</label>
	 				<c:choose>
					   <c:when test="${cdImg== null}"> 
	  						<img src="${pageContext.request.contextPath}/images/upload.png" name="cashierDesk_img" id="cashierDesk_img" onclick="show_img.open_file('cdImg')">
					   </c:when>
					   <c:otherwise>
	  						<img src="${pageContext.request.contextPath}/Common/downloadPhoto?url=${cdImg}" name="cashierDesk_img" id="cashierDesk_img" onclick="show_img.open_file('cdImg')">
					   </c:otherwise>
					</c:choose>
					<input type="file" style="display: none" id="cdImg" name="cdImg" onchange="show_img.change('cdImg','cashierDesk_img')"/>
				</p>
				<p style="height: 150px;">
					<label>加油机：</label>
					<c:choose>
					   <c:when test="${tankerImg== null}"> 
	  						<img src="${pageContext.request.contextPath}/images/upload.png" name="tanker_img" id="tanker_img" onclick="show_img.open_file('tankerImg')">
					   </c:when>
					   <c:otherwise>
	  						<img src="${pageContext.request.contextPath}/Common/downloadPhoto?url=${tankerImg}" name="tanker_img" id="tanker_img" onclick="show_img.open_file('tankerImg')">
					   </c:otherwise>
					</c:choose>
					<input type="file" style="display: none" id="tankerImg" name="tankerImg" onchange="show_img.change('tankerImg','tanker_img')"/>
				</p>
				<p style="height: 150px;">
					<label>门牌号：</label>
					<c:choose>
					   <c:when test="${hnImg== null}"> 
  							<img src="${pageContext.request.contextPath}/images/upload.png" name="houseNumber_img" id="houseNumber_img" onclick="show_img.open_file('hnImg')">
					   </c:when>
					   <c:otherwise>
  							<img src="${pageContext.request.contextPath}/Common/downloadPhoto?url=${hnImg}" name="houseNumber_img" id="houseNumber_img" onclick="show_img.open_file('hnImg')">
					   </c:otherwise>
					</c:choose>
					<input type="file" style="display: none" id="hnImg" name="hnImg" onchange="show_img.change('hnImg','houseNumber_img')"/>
				</p>
				<p style="height: 150px;">
					<label>便利店：</label>
					<c:choose>
					   <c:when test="${CVSImg== null}"> 
  							<img src="${pageContext.request.contextPath}/images/upload.png" name="CVS_img" id="CVS_img" onclick="show_img.open_file('CVSImg')">
					   </c:when>
					   <c:otherwise>
  							<img src="${pageContext.request.contextPath}/Common/downloadPhoto?url=${CVSImg}" name="CVS_img" id="CVS_img" onclick="show_img.open_file('CVSImg')">
					   </c:otherwise>
					</c:choose>
					<input type="file" style="display: none" id="CVSImg" name="CVSImg" onchange="show_img.change('CVSImg','CVS_img')"/>
				</p>
				<p style="height: 150px;">
					<label>洗手间：</label>
					<c:choose>
					   <c:when test="${WCImg== null}"> 
  							<img src="${pageContext.request.contextPath}/images/upload.png" name="WC_img" id="WC_img" onclick="show_img.open_file('WCImg')">
					   </c:when>
					   <c:otherwise>
  							<img src="${pageContext.request.contextPath}/Common/downloadPhoto?url=${WCImg}" name="WC_img" id="WC_img" onclick="show_img.open_file('WCImg')">
					   </c:otherwise>
					</c:choose>
					<input type="file" style="display: none" id="WCImg" name="WCImg" onchange="show_img.change('WCImg','WC_img')"/>
				</p>
				<p style="height: 150px;">
					<label>洗车间：</label>
					<c:choose>
					   <c:when test="${CWImg== null}"> 
  							<img src="${pageContext.request.contextPath}/images/upload.png" name="CW_img" id="CW_img" onclick="show_img.open_file('CWImg')">
					   </c:when>
					   <c:otherwise>
  							<img src="${pageContext.request.contextPath}/Common/downloadPhoto?url=${WCImg}" name="CW_img" id="CW_img" onclick="show_img.open_file('CWImg')">
					   </c:otherwise>
					</c:choose>
					<input type="file" style="display: none" id="CWImg" name="CWImg" onchange="show_img.change('CWImg','CW_img')"/>
				</p>
				<p style="height: 150px;">
					<label>维修间：</label>
					<c:choose>
					   <c:when test="${repairImg== null}"> 
  							<img src="${pageContext.request.contextPath}/images/upload.png" name="repair_img" id="repair_img" onclick="show_img.open_file('repairImg')">
					   </c:when>
					   <c:otherwise>
  							<img src="${pageContext.request.contextPath}/Common/downloadPhoto?url=${repairImg}" name="repair_img" id="repair_img" onclick="show_img.open_file('repairImg')">
					   </c:otherwise>
					</c:choose>
					<input type="file" style="display: none" id="repairImg" name="repairImg" onchange="show_img.change('repairImg','repair_img')"/>
				</p>
			</div>
	 			<div class="formBar">
				<ul>
					<li><div class="buttonActive"><div class="buttonContent"><button type="button" onclick="update_station.from_submit()">保存</button></div></div></li>
					<li>
						<div class="button"><div class="buttonContent"><button class="close" type="button">取消</button></div></div>
					</li>
				</ul>
			</div>
  		</form>
  <script Charset="UTF-8" type="text/javascript">
  var update_station ={
			list_city :function () {
		      	 $(from).find("#province").val($(from).find("#provinceId").find("option:selected").text());
				var provinceId =  $(from).find("#provinceId").val();
				
		        var result = "<option value=''>选择城市</option>";
				if(provinceId == ""){
					 $(from).find("#cityId").html('');
					 $(from).find("#cityId").append(result);
					return;
				}
		      	$.post("${pageContext.request.contextPath}/address/listCity",{provinceId:$(from).find("#provinceId").val()}, 
		    			   function(data){
					 if(data.code == 200){
						 var old_cityId = $(from).find("#old_cityId").val();
			                $.each(data.list,function(n,value){
			                	if(old_cityId*1 == value.cityId*1){
			                   		result +="<option value='"+value.cityId+"' selected='selected'>"+value.city+"</option>";
			                   	}else{
			                         result +="<option value='"+value.cityId+"'>"+value.city+"</option>";
			                   	}
			                });
			                $(from).find("#cityId").html('');
			                $(from).find("#cityId").append(result);
			         }
				  });
			},
			from_submit :function (){  
				var provinceId =  $(from).find("#provinceId").val();
				var cityId =  $(from).find("#cityId").val();
				if(provinceId == ""){
					alertMsg.error("省份不能为空");
					return false;
				}
				if(cityId == ""){
					alertMsg.error("城市不能为空");
					return false;
				}
				 var fileSize = $("input[type=file]").size;
				 console.debug($("input[type=file]"));
				 //size in kb
				 fileSize = fileSize / 1048576; //size in mb 
				$(from).submit(); 
			    
			} 	
	};
    var from = $("#update_station_form");
	$(function(){
		$.post("${pageContext.request.contextPath}/address/listProvinces", 
 			   function(data){
	   		 if(data.code == 200){
	   			 var old_provinceId = $(from).find("#old_provinceId").val();
	              var result = "<option value=''>选择省份</option>";
	              $.each(data.list,function(n,value){
	            	  if(old_provinceId*1 == value.provinceId*1){
	                  		result +="<option value='"+value.provinceId+"' selected='selected'>"+value.province+"</option>";
	                  	}else{
	                        result +="<option value='"+value.provinceId+"'>"+value.province+"</option>";
	                  	}
	              });
	              $(from).find("#provinceId").html('');
	              $(from).find("#provinceId").append(result);
	              update_station.list_city();
	           }
 		});
   	
   	 $(from).find("#provinceId").change(function(){update_station.list_city()});
		    	 $(from).find("#cityId").change(function () {
		    		 $(from).find("#city").val( $(from).find("#cityId").find("option:selected").text());
//	 	        	$.post("${pageContext.request.contextPath}/address/listAreas",{cityId:$("#cityId").val()}, 
//	        			   function(data){
//	     	    		 if(data.code == 200){
//	     	                    var result = "<option>选择区域</option>";
//	     	                    $.each(data.list,function(n,value){
//	     	                    	console.debug(value.areaId);
//	     	                    	result +="<option value='"+value.areaId+"'>"+value.area+"</option>";
//	     	                    });
//	    				    		 $("#areaId").html('');
//	 	                   		 $("#areaId").append(result);
//	     	                }
//	        			   });
		        });

	});
	
	
 </script>
</div>
	  